/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2022-06-23 20:18:13
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-06-23 20:30:17
 */
package com.chushouya.controller.partner;

import com.chushouya.common.annotations.SignValidate;
import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.lang.Beans;
import com.general.framework.core.schema.PageResult;
import com.general.framework.core.schema.Response;
import com.chushouya.product.dto.api.product.ProductApiQuery;
import com.chushouya.product.dto.api.product.ProductListApiDTO;
import com.chushouya.product.dto.partner.product.ProductPartnerApiQuery;
import com.chushouya.product.service.api.ProductHotApiService;
import com.chushouya.product.service.api.ProductApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@Api(tags =  ServiceType.OPENAPI + "产品接口")
@RestController
@RequestMapping( ServiceType.OPENAPI + "/product")
@Slf4j
public class ProductPartnerController {
    @Resource
    private ProductApiService productService;

    @Resource
    private ProductHotApiService productHotService;


    @ApiOperation("获取产品分页接口")
    @GetMapping("/list")
    @SignValidate
    public Response<PageResult<ProductListApiDTO>> list(ProductPartnerApiQuery query) {
        ProductApiQuery productApiQuery = Beans.copy(query, ProductApiQuery.class);
        return Response.success(productService.selectPage(productApiQuery));
    }

    @ApiOperation("搜索产品列表接口")
    @GetMapping("/search")
    @SignValidate
    public Response<List<ProductListApiDTO>> search(ProductPartnerApiQuery query) {
        ProductApiQuery productApiQuery = Beans.copy(query, ProductApiQuery.class);
        return Response.success(productService.search(productApiQuery));
    }
}
